<?php
require("resource.inf");
/*this script formats a tab bar based
on data as described in $tablbl array*/

/*arguments
$tabndx is the index of the current up tab (beginning at 0)*/

/*check the validity of $tabndx*/
$tabndx=(int)$tabndx;
if($tabndx < 0 || $tabndx > count($tablbl))
	$tabndx=0;

if($lang != 'frn')
	$lang='eng';
	
/**************************************/
/*this function formats a sub cell in the tab cell
whose name is "tab$tail" and label is tablbl[$i][$$lang]*/

function tab($tail,$i) {

global $tablbl,$lang,$tabndx;

$eng=0; $frn=1;
	
echo "\t\t    <td nowrap valign='bottom'><img src='inc/images/tab$tail.gif' border='0'></td>\n";

if($i<count($tablbl)) {
	if($i != $tabndx) {
		/*replace any previous occurence of tabndx*/
		$qrystr=str_replace("&tabndx=$tabndx","",$GLOBALS[QUERY_STRING]);
		
		/*print correct link with all other parameters*/
		$href="disp.php3?$qrystr&tabndx=$i";
		
		echo "\t\t    <td nowrap valign='middle' bgcolor='#B8B622'><a class='connect' href='$href'>".$tablbl[$i][$$lang]."</a></td>\n";
	}
	else
		echo "\t\t    <td nowrap valign='middle' bgcolor='#638598'><font size='2' face='Arial,Courier,sans-serif' color='#FFFF00'>".$tablbl[$i][$$lang]."</font></td>\n";
}
return;	
}

/**************************************/

echo "<table bgColor='yellow' border=0 cellPadding=0 cellSpacing=0 width='100%' height='10'>\n\t  <tr><td>&nbsp;</td></tr>\n";
echo "\t  <tr>\n\t    <td>\n";
echo "\t\t<table bgColor='yellow' border=0 cellPadding=0 cellSpacing=0 width='50'>\n\t\t  <tr>\n";
echo "\t\t    <td nowrap valign='bottom'><img border='0' src='inc/images/pad.gif'></td>\n";

/*scan tablbl array*/
for($i=0;$i<count($tablbl);$i++) {
	if(!$i) {
		if(!$tabndx) {
			tab("ul",$i);
		}
		else {
			tab("dl",$i);
		}
	}
	else {
		/*if uptab is the previous*/
		if($tabndx == $i-1) {
			tab("ud",$i);	
		}
		/*if uptab is the current*/
		else if($tabndx == $i) {
			tab("du",$i);
		}
		/*else it's the joint between 2 downtabs*/
		else {
			tab("dd",$i);
		}
	}
}
/*last gif may be tabdr or tabur*/
if($tabndx == $i-1) {
	tab("ur",$i);
}
else {
	tab("dr",$i);	
}
echo "\t\t  </tr>\n\t\t</table>\n\t    </td>\n\t  </tr>\n\t</table>\n";
?>